package org.jeecg.modules.product.job.ticket.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import freemarker.cache.ClassTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.dao.DataAccessException;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.product.job.JSAAnalysislibrary.entity.TbJobJsaAnalysisLibrary;
import org.jeecg.modules.product.job.JSAAnalysislibrary.service.ITbJobJsaAnalysisLibraryService;
import org.jeecg.modules.product.job.SafetyMeasureLibrary.entity.TbJobSafetyMeasureLibrary;
import org.jeecg.modules.product.job.SafetyMeasureLibrary.service.ITbJobSafetyMeasureLibraryService;
import org.jeecg.modules.product.job.SampleAnalysisLibrary.entity.TbJobSampleAnalysisLibrary;
import org.jeecg.modules.product.job.SampleAnalysisLibrary.service.ITbJobSampleAnalysisLibraryService;
import org.jeecg.modules.product.job.SecurityDisclosureConfig.entity.TbJobTicketSecurityDisclosureConfig;
import org.jeecg.modules.product.job.SecurityDisclosureConfig.service.ITbJobTicketSecurityDisclosureConfigService;
import org.jeecg.modules.product.job.ticket.entity.*;
import org.jeecg.modules.product.job.ticket.service.*;
import org.jeecg.modules.product.job.ticket.vo.CommonVo;
import org.jeecg.modules.product.job.ticket.vo.TbJobTicketVo;
import org.jeecg.modules.product.risk.vo.TbBaseCheckPage;
import org.jeecg.modules.product.rule.JobTicketNumberRule;
import org.jeecg.modules.product.until.TicketGenerator;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;

 /**
 * @Description: 电子作业票
 * @Author: jeecg-boot
 * @Date:   2024-08-08
 * @Version: V1.0
 */
@Tag(name="电子作业票")
@RestController
@RequestMapping("/TbJobTicket/tbJobTicket")
@Slf4j
public class TbJobTicketController extends JeecgController<TbJobTicket, ITbJobTicketService> {

	@Autowired
	private ITbJobTicketService tbJobTicketService;

	@Autowired
	private ITbJobTicketAuditRecordService tbJobTicketAuditRecordService;

	@Autowired
	private ITbJobTicketJsaAnalyzeService tbJobTicketJsaAnalyzeService;

	@Autowired
	private ITbJobTicketGasAnalysisService tbJobTicketGasAnalysisService;

	@Autowired
	private ITbJobTicketMeasureRecordService tbJobTicketMeasureRecordService;

	@Autowired
	private ITbJobTicketExamineRecordService tbJobTicketExamineRecordService;

	@Autowired
	private ITbJobTicketSecurityDisclosureRecordService tbJobTicketSecurityDisclosureRecordService;

	@Autowired
	private ITbJobTicketCourseRecordService tbJobTicketCourseRecordService;

	 @Autowired
	 private ITbJobTicketAcceptanceCheckRecordService tbJobTicketAcceptanceCheckRecordService;

	@Autowired
	private ITbJobTicketProblemRecordService tbJobTicketProblemRecordService;

	@Autowired
	private ITbJobTicketViolationCaptureService tbJobTicketViolationCaptureService;

	 @Autowired
	 private ITbJobTicketApprovalConfigService tbJobTicketApprovalConfigService;

	 @Autowired
	 private ITbJobTicketAcceptanceCheckConfigService tbJobTicketAcceptanceCheckConfigService;

	 @Autowired
	 private ITbJobJsaAnalysisLibraryService tbJobJsaAnalysisLibraryService;
	 @Autowired
	 private ITbJobSampleAnalysisLibraryService tbJobSampleAnalysisLibraryService;
	 @Autowired
	 private ITbJobSafetyMeasureLibraryService tbJobSafetyMeasureLibraryService;
	 @Autowired
	 private ITbJobTicketSecurityDisclosureConfigService tbJobTicketSecurityDisclosureConfigService;
	 @Autowired
	 private ITbJobTicketEventsService tbJobTicketEventsService;

	 private final Configuration cfg;
	 @Autowired
	 private Configuration freeMarkerConfiguration;

	 public TbJobTicketController() throws IOException {
		 cfg = new Configuration(Configuration.VERSION_2_3_31);
		 // 设置模板的加载路径，这里假设模板文件放在src/main/resources/templates下
		 // 注意：FreeMarker的ClassLoaderTemplateLoader可能不适用于从JAR文件中加载模板
		 // 你可以使用FileTemplateLoader，但需要注意在部署时模板文件的路径
		 // 这里为了示例，我们使用ClassTemplateLoader，它通常用于开发环境
		 cfg.setTemplateLoader(new ClassTemplateLoader(getClass(), "/templates"));
		 cfg.setDefaultEncoding("UTF-8");
		 cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
		 cfg.setLogTemplateExceptions(false);
		 cfg.setWrapUncheckedExceptions(true);
		 cfg.setFallbackOnNullLoopVariable(false);
	 }

     /*---------------------------------主表处理-begin-------------------------------------*/

	/**
	 * 分页列表查询
	 * @param tbJobTicket
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "电子作业票-分页列表查询")
	@Operation(summary="电子作业票-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<TbJobTicket>> queryPageList(TbJobTicket tbJobTicket,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<TbJobTicket> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicket, req.getParameterMap());
		queryWrapper.orderByDesc("create_time");
		queryWrapper.eq("deleted","0");
		Page<TbJobTicket> page = new Page<TbJobTicket>(pageNo, pageSize);
		IPage<TbJobTicket> pageList = tbJobTicketService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
     *   添加
     * @param tbJobTicket
     * @return
     */
    @AutoLog(value = "电子作业票-添加")
    @Operation(summary="电子作业票-添加")
    @RequiresPermissions("TbJobTicket:tb_job_ticket:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody TbJobTicket tbJobTicket) {
        tbJobTicketService.save(tbJobTicket);
        return Result.OK("添加成功！");
    }

	 /**
	  *   作业活动生成票据,pc端
	  * @param tbJobTicket
	  * @return
	  */
	 @AutoLog(value = "电子作业票-生成票据")
	 @Operation(summary="电子作业票-生成票据")
	 //@RequiresPermissions("TbJobTicket:tb_job_ticket:add")
	 @PostMapping(value = "/generateTickets")
	 @Transactional(rollbackFor = DataAccessException.class)
	 public Result<String> generateTickets(@RequestBody TbJobTicket tbJobTicket) {
		 /*根据作业活动id查询作业活动*/
		 TbJobTicketEvents jobTicketEvents = tbJobTicketEventsService.getById(tbJobTicket.getEventsId());
		 /*1:预约，2：办理3,：审批中4：审批完成，5：已验收*/
		 tbJobTicket.setStatus("3");
		 /*记录作业活动开始时间，作为作业票的活动时间*/
		 tbJobTicket.setEventDate(null != jobTicketEvents ? jobTicketEvents.getPlanStartDate():null);
		 tbJobTicketService.save(tbJobTicket);
		 relationalParameterSaving(tbJobTicket);
		 return Result.OK("生成票据成功！");
	 }

	 /**
	  *   作业活动生成票据,app端
	  * @param tbJobTicketVo
	  * @return
	  */
	 @AutoLog(value = "电子作业票-生成票据")
	 @Operation(summary="电子作业票-生成票据")
	 @PostMapping(value = "/generateTicketsApp")
	 @Transactional(rollbackFor = DataAccessException.class)
	 public Result<String> generateTicketsApp(@RequestBody TbJobTicketVo tbJobTicketVo) {
		 TbJobTicket tbJobTicket = new TbJobTicket();
		 BeanUtils.copyProperties(tbJobTicketVo, tbJobTicket);
		 /*1:预约，2：办理3,：审批中4：审批完成，5：已验收*/
		 tbJobTicket.setStatus("3");
		 tbJobTicket.setEventDate(new Date());
		 tbJobTicketService.save(tbJobTicket);
		 relationalParameterSaving(tbJobTicket);
		 return Result.OK("生成票据成功！");
	 }



	 private void relationalParameterSaving(TbJobTicket tbJobTicket){
		 /*这段代码的意思是用来配置作业票的签发信息*/
		 //查询对应的签发节点并赋值给作业票的签发记录信息，用来做签名记录
		 /* 动火作业：1，临时用电：2，吊装作业：3，盲板抽堵：4，动土作业：5，
      		断路作业：6，受限空间作业：7，高处作业：8，通用作业：9，带压堵漏：10.
      		1,3,8对应的是动火，吊装，高处，这三个有对应的级别类型，所以而且由于级别字段同所以需要单独处理*/
		 /*存储审核记录*/
		 QueryWrapper<TbJobTicketApprovalConfig> queryWrapper = new QueryWrapper<>();
		 if(tbJobTicket.getJobType().equals("1")){
			 queryWrapper.eq("job_type",tbJobTicket.getJobType());
			 queryWrapper.like("level",tbJobTicket.getHotLevel());
		 }else if (tbJobTicket.getJobType().equals("3")){
			 queryWrapper.eq("job_type",tbJobTicket.getJobType());
			 queryWrapper.like("level",tbJobTicket.getLiftingJobLevel());
		 }else if (tbJobTicket.getJobType().equals("8")){
			 queryWrapper.eq("job_type",tbJobTicket.getJobType());
			 queryWrapper.like("level",tbJobTicket.getHighLevel());
		 }else{
			 queryWrapper.eq("job_type",tbJobTicket.getJobType());
		 }
		 /*根据排序排序，用于最终作业票暂展示顺序不混乱*/
		 queryWrapper.orderByDesc("sequence");
		 List<TbJobTicketExamineRecord> examineRecordList = new ArrayList<>();
		 tbJobTicketApprovalConfigService.list(queryWrapper).forEach(item-> {
			 TbJobTicketExamineRecord examineRecord = new TbJobTicketExamineRecord();
			 examineRecord.setAuditorRole(item.getIssuingOfficerFields());
			 examineRecord.setSequence(item.getSequence());
			 examineRecord.setJobTicketId(tbJobTicket.getId());
			 examineRecord.setDeleted("0");
			 examineRecordList.add(examineRecord);
		 });
		 tbJobTicketExamineRecordService.saveBatch(examineRecordList);

		 /*这里配置作业票验收节点*/
		 QueryWrapper<TbJobTicketAcceptanceCheckConfig> queryWrapperAcceptanceCheck = new QueryWrapper<>();
		 queryWrapperAcceptanceCheck.eq("job_type",tbJobTicket.getJobType());
		 List<TbJobTicketAcceptanceCheckRecord> acceptanceCheckRecordList = new ArrayList<>();
		 tbJobTicketAcceptanceCheckConfigService.list(queryWrapperAcceptanceCheck).forEach(item-> {
			 TbJobTicketAcceptanceCheckRecord acceptanceCheckRecord = new TbJobTicketAcceptanceCheckRecord();
			 acceptanceCheckRecord.setJobTicketId(tbJobTicket.getId());
			 acceptanceCheckRecord.setAcceptanceCheckRole(item.getApproverFields());
			 acceptanceCheckRecord.setSequence(item.getSequence());
			 acceptanceCheckRecord.setDeleted("0");
			 acceptanceCheckRecordList.add(acceptanceCheckRecord);
		 });
		 tbJobTicketAcceptanceCheckRecordService.saveBatch(acceptanceCheckRecordList);

		 /*这里配置作业票jsp分析数据*/
		 QueryWrapper<TbJobJsaAnalysisLibrary> queryWrapperJsaAnalysisLibrary = new QueryWrapper<>();
		 queryWrapperJsaAnalysisLibrary.eq("type",tbJobTicket.getJobType());
		 List<TbJobTicketJsaAnalyze> jobTicketJsaAnalyzeList = new ArrayList<>();
		 tbJobJsaAnalysisLibraryService.list(queryWrapperJsaAnalysisLibrary).forEach(item-> {
			 TbJobTicketJsaAnalyze jsaAnalyze = new TbJobTicketJsaAnalyze();
			 jsaAnalyze.setJobTicketId(tbJobTicket.getId());
			 jsaAnalyze.setJobType(item.getType());
			 jsaAnalyze.setHazardFactorName(item.getHazardAnalysis());
			 jsaAnalyze.setControlMeasureName(item.getMeasureControl());
			 jsaAnalyze.setConfirmPost(item.getConfirmPostion());
			 jsaAnalyze.setIsNotInvolves("0");
			 jsaAnalyze.setDeleted("0");
			 jobTicketJsaAnalyzeList.add(jsaAnalyze);
		 });
		 tbJobTicketJsaAnalyzeService.saveBatch(jobTicketJsaAnalyzeList);

		 /*这里配置作业票管控措施数据*/
		 QueryWrapper<TbJobSafetyMeasureLibrary> queryWrapperSafetyMeasureLibrary = new QueryWrapper<>();
		 queryWrapperSafetyMeasureLibrary.eq("type",tbJobTicket.getJobType());
		 //queryWrapperSafetyMeasureLibrary.eq("deleted","0");
		 List<TbJobTicketMeasureRecord> measureRecordList = new ArrayList<>();
		 tbJobSafetyMeasureLibraryService.list(queryWrapperSafetyMeasureLibrary).forEach(item-> {
			 TbJobTicketMeasureRecord measureRecord = new TbJobTicketMeasureRecord();
			 measureRecord.setJobTicketId(tbJobTicket.getId());
			 measureRecord.setMeasure(item.getMeasure());
			 measureRecord.setVerifyPost(item.getConfirmPostion());
			 measureRecord.setIsNot(item.getIsNot());
			 measureRecord.setDeleted("0");
			 measureRecordList.add(measureRecord);
		 });
		 tbJobTicketMeasureRecordService.saveBatch(measureRecordList);

		 /*这里配置作业票气体分析数据*/
		 if(tbJobTicket.getJobType().equals("1") || tbJobTicket.getJobType().equals("2") || tbJobTicket.getJobType().equals("7")){
			 QueryWrapper<TbJobSampleAnalysisLibrary> queryWrapperSampleAnalysisLibrary = new QueryWrapper<>();
			 queryWrapperSampleAnalysisLibrary.eq("status","1");
			 List<TbJobTicketGasAnalysis> gasAnalysisList = new ArrayList<>();
			 tbJobSampleAnalysisLibraryService.list(queryWrapperSampleAnalysisLibrary).forEach(item ->{
				 TbJobTicketGasAnalysis gasAnalysisRecord = new TbJobTicketGasAnalysis();
				 gasAnalysisRecord.setJobTicketId(tbJobTicket.getId());
				 gasAnalysisRecord.setAnalysisItem(item.getName());
				 gasAnalysisRecord.setUnit(item.getUnit());
				 /*制定气体检测标准，最小值到最大值阈值*/
				 gasAnalysisRecord.setAcceptanceStandard(item.getMinValue() +"-" + item.getMaxValue());
				 gasAnalysisRecord.setDeleted("0");
				 gasAnalysisList.add(gasAnalysisRecord);
			 });
			 tbJobTicketGasAnalysisService.saveBatch(gasAnalysisList);
		 }

		 /*这里配置作业票的安全交底措施信息*/
		 TbJobTicketSecurityDisclosureConfig securityDisclosureConfig = tbJobTicketSecurityDisclosureConfigService.getOne(new QueryWrapper<TbJobTicketSecurityDisclosureConfig>().eq("deleted","0"));
		 TbJobTicketSecurityDisclosureRecord securityDisclosureRecord = getTbJobTicketSecurityDisclosureRecord(tbJobTicket, securityDisclosureConfig);
		 tbJobTicketSecurityDisclosureRecordService.save(securityDisclosureRecord);
	 }

	 private static @NotNull TbJobTicketSecurityDisclosureRecord getTbJobTicketSecurityDisclosureRecord(TbJobTicket tbJobTicket, TbJobTicketSecurityDisclosureConfig securityDisclosureConfig) {
		 TbJobTicketSecurityDisclosureRecord securityDisclosureRecord = new TbJobTicketSecurityDisclosureRecord();
		 securityDisclosureRecord.setJobTicketId(tbJobTicket.getId());
		 securityDisclosureRecord.setJobEnvironment(securityDisclosureConfig.getJobEnvironment());
		 securityDisclosureRecord.setPreventiveMeasures(securityDisclosureConfig.getPreventiveMeasures());
		 securityDisclosureRecord.setEmergencyMeasure(securityDisclosureConfig.getEmergencyMeasure());
		 securityDisclosureRecord.setAttentionItem(securityDisclosureConfig.getAttentionItem());
		 securityDisclosureRecord.setDeleted("0");
		 return securityDisclosureRecord;
	 }

	 /**
     *  编辑
     * @param tbJobTicket
     * @return
     */
    @AutoLog(value = "电子作业票-编辑")
    @Operation(summary="电子作业票-编辑")
    //@RequiresPermissions("TbJobTicket:tb_job_ticket:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody TbJobTicket tbJobTicket) {
        tbJobTicketService.updateById(tbJobTicket);
        return Result.OK("编辑成功!");
    }

    /**
     * 通过id删除
     * @param id
     * @return
     */
    @AutoLog(value = "电子作业票-通过id删除")
    @Operation(summary="电子作业票-通过id删除")
    //@RequiresPermissions("TbJobTicket:tb_job_ticket:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        tbJobTicketService.delMain(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @AutoLog(value = "电子作业票-批量删除")
    @Operation(summary="电子作业票-批量删除")
    //@RequiresPermissions("TbJobTicket:tb_job_ticket:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.tbJobTicketService.delBatchMain(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }

    /**
     * 导出
     * @return
     */
    @RequiresPermissions("TbJobTicket:tb_job_ticket:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, TbJobTicket tbJobTicket) {
        return super.exportXls(request, tbJobTicket, TbJobTicket.class, "电子作业票");
    }

    /**
     * 导入
     * @return
     */
    @RequiresPermissions("TbJobTicket:tb_job_ticket:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, TbJobTicket.class);
    }

	 /**
	  * 通过id发起签批
	  * @param id
	  * @return
	  */
	 @AutoLog(value = "电子作业票-通过id发起签批")
	 @Operation(summary="电子作业票-通过id发起签批")
	 @GetMapping(value = "/initiateApprovalById")
	 public Result<String> initiateApprovalById(@RequestParam(name="id",required=true) String id) {
		 UpdateWrapper<TbJobTicket> updateWrapper = new UpdateWrapper<>();
		 updateWrapper.eq("id", id);
		 updateWrapper.set("status", "3");
		 tbJobTicketService.update(updateWrapper);
		 return Result.OK("发起签批成功!");
	 }

	 /**
	  * 分页列表查询
	  * @param tbJobTicket
	  * @param pageNo
	  * @param pageSize
	  * @param req
	  * @return
	  */
	 //@AutoLog(value = "电子作业票-分页列表查询")
	 @Operation(summary="电子作业票-分页列表查询")
	 @GetMapping(value = "/generateExportAndDownload")
	 public ResponseEntity<ByteArrayResource> generateReportAndDownload(TbJobTicket tbJobTicket,
																@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																HttpServletRequest req) throws IOException, TemplateException {
		 QueryWrapper<TbJobTicket> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicket, req.getParameterMap());
		 Page<TbJobTicket> page = new Page<TbJobTicket>(pageNo, pageSize);
		 IPage<TbJobTicket> pageList = tbJobTicketService.page(page, queryWrapper);

		 // 设置HTTP响应头以指示文件下载
		 HttpHeaders headers = new HttpHeaders();
		 ByteArrayOutputStream out = new ByteArrayOutputStream();
		 Map<String, Object> dataModel = new HashMap<>();

		 // 使用FreeMarker生成报告内容
		 Template template = null;
		 if(tbJobTicket.getJobType().equals("1")){
			 dataModel.put("reportTitle", "动火安全作业证");
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("2")){
			 dataModel.put("reportTitle", "临时用电安全作业证");
			 template = cfg.getTemplate("TemporaryElectricityConsumptionTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("3")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("4")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("5")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("6")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("7")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 } else if (tbJobTicket.getJobType().equals("8")){
			 template = cfg.getTemplate("HotWorkingTemplate.ftl");
		 }
		 TbJobTicket jobTicket = pageList.getRecords().get(0);
		 dataModel.put("number", jobTicket.getNumber());
		 dataModel.put("content", jobTicket.getContent());
		 dataModel.put("applyTime", jobTicket.getApplyTime());
		 dataModel.put("jobReason", jobTicket.getJobReason());


		 try {
			 //dataModel.put("code", pageList.getreportCode());
			 try (Writer fileWriter = new OutputStreamWriter(out, "UTF-8")) {
				 template.process(dataModel, fileWriter);
			 }
			 headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"report.doc\""); // 注意：这里假设生成的是.doc文件，如果是.docx或其他格式，请相应更改
			 headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 // 创建并返回ResponseEntity
		 ByteArrayResource resource = new ByteArrayResource(out.toByteArray()) {
			 @Override
			 public boolean exists() {
				 // 必须重写此方法，否则Spring会在调用getInputStream时检查文件是否存在
				 return true;
			 }
		 };
		 return ResponseEntity.ok()
				 .headers(headers)
				 .contentLength(out.size())
				 .contentType(MediaType.APPLICATION_OCTET_STREAM)
				 .body(resource);
	 }

	 @GetMapping("/generateTemplate")
	 public ResponseEntity<byte[]> generateTemplate(
			 @RequestParam String title,
			 @RequestParam String header,
			 @RequestParam String content,
			 HttpServletResponse response) throws IOException, TemplateException {

		 // 设置响应头
		 response.setContentType("application/octet-stream");
		 response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template.html");

		 // 加载模板
		 Template template = freeMarkerConfiguration.getTemplate("HotWorkingTemplate.ftl");

		 // 填充数据
		 Map<String, Object> dataModel = new HashMap<>();
		 dataModel.put("title", title);
		 dataModel.put("header", header);
		 dataModel.put("content", content);

		 // 合并模板和数据
		 StringWriter out = new StringWriter();
		 template.process(dataModel, out);

		 // 返回生成的HTML内容作为字节流
		 byte[] contentBytes = out.toString().getBytes(StandardCharsets.UTF_8);
		 return new ResponseEntity<>(contentBytes, HttpStatus.OK);
	 }

	 //@AutoLog(value = "电子作业票-分页列表查询")
	 @Operation(summary="电子作业票-分页列表查询关联作业票")
	 @GetMapping(value = "/listForRelevanceJobTicket")
	 public Result<IPage<TbJobTicket>> queryPageListForRelevanceJobTicket(TbJobTicket tbJobTicket,
													 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
													 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
													 HttpServletRequest req) {
		 QueryWrapper<TbJobTicket> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicket, req.getParameterMap());
		 Page<TbJobTicket> page = new Page<TbJobTicket>(pageNo, pageSize);
		 queryWrapper.select("id","number","job_type","apply_time","device","content","cell");
		 IPage<TbJobTicket> pageList = tbJobTicketService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }
	/*---------------------------------主表处理-end-------------------------------------*/
	

    /*--------------------------------子表处理-电子作业票审核记录-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票审核记录-通过主表ID查询")
	@Operation(summary="电子作业票审核记录-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketAuditRecordByMainId")
    public Result<IPage<TbJobTicketAuditRecord>> listTbJobTicketAuditRecordByMainId(TbJobTicketAuditRecord tbJobTicketAuditRecord,
																					@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
																					@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
																					HttpServletRequest req) {
        QueryWrapper<TbJobTicketAuditRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketAuditRecord, req.getParameterMap());
        Page<TbJobTicketAuditRecord> page = new Page<TbJobTicketAuditRecord>(pageNo, pageSize);
        IPage<TbJobTicketAuditRecord> pageList = tbJobTicketAuditRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketAuditRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-添加")
	@Operation(summary="电子作业票审核记录-添加")
	@PostMapping(value = "/addTbJobTicketAuditRecord")
	public Result<String> addTbJobTicketAuditRecord(@RequestBody TbJobTicketAuditRecord tbJobTicketAuditRecord) {
		tbJobTicketAuditRecordService.save(tbJobTicketAuditRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketAuditRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-编辑")
	@Operation(summary="电子作业票审核记录-编辑")
	@RequestMapping(value = "/editTbJobTicketAuditRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketAuditRecord(@RequestBody TbJobTicketAuditRecord tbJobTicketAuditRecord) {
		tbJobTicketAuditRecordService.updateById(tbJobTicketAuditRecord);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-通过id删除")
	@Operation(summary="电子作业票审核记录-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketAuditRecord")
	public Result<String> deleteTbJobTicketAuditRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketAuditRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-批量删除")
	@Operation(summary="电子作业票审核记录-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketAuditRecord")
	public Result<String> deleteBatchTbJobTicketAuditRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketAuditRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketAuditRecord")
    public ModelAndView exportTbJobTicketAuditRecord(HttpServletRequest request, TbJobTicketAuditRecord tbJobTicketAuditRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketAuditRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketAuditRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketAuditRecord> pageList = tbJobTicketAuditRecordService.list(queryWrapper);
		 List<TbJobTicketAuditRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票审核记录");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketAuditRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票审核记录报表", "导出人:" + sysUser.getRealname(), "电子作业票审核记录"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketAuditRecord/{mainId}")
    public Result<?> importTbJobTicketAuditRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketAuditRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketAuditRecord.class, params);
				 for (TbJobTicketAuditRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketAuditRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票审核记录-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票JSA分析-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票JSA分析-通过主表ID查询")
	@Operation(summary="电子作业票JSA分析-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketJsaAnalyzeByMainId")
    public Result<IPage<TbJobTicketJsaAnalyze>> listTbJobTicketJsaAnalyzeByMainId(TbJobTicketJsaAnalyze tbJobTicketJsaAnalyze,
																				  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
																				  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
																				  HttpServletRequest req) {
        QueryWrapper<TbJobTicketJsaAnalyze> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketJsaAnalyze, req.getParameterMap());
        Page<TbJobTicketJsaAnalyze> page = new Page<TbJobTicketJsaAnalyze>(pageNo, pageSize);
        IPage<TbJobTicketJsaAnalyze> pageList = tbJobTicketJsaAnalyzeService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketJsaAnalyze
	 * @return
	 */
	@AutoLog(value = "电子作业票JSA分析-添加")
	@Operation(summary="电子作业票JSA分析-添加")
	@PostMapping(value = "/addTbJobTicketJsaAnalyze")
	public Result<String> addTbJobTicketJsaAnalyze(@RequestBody TbJobTicketJsaAnalyze tbJobTicketJsaAnalyze) {
		tbJobTicketJsaAnalyzeService.save(tbJobTicketJsaAnalyze);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketJsaAnalyze
	 * @return
	 */
	@AutoLog(value = "电子作业票JSA分析-编辑")
	@Operation(summary="电子作业票JSA分析-编辑")
	@RequestMapping(value = "/editTbJobTicketJsaAnalyze", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketJsaAnalyze(@RequestBody TbJobTicketJsaAnalyze tbJobTicketJsaAnalyze) {
		tbJobTicketJsaAnalyzeService.updateById(tbJobTicketJsaAnalyze);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票JSA分析-通过id删除")
	@Operation(summary="电子作业票JSA分析-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketJsaAnalyze")
	public Result<String> deleteTbJobTicketJsaAnalyze(@RequestParam(name="id",required=true) String id) {
		tbJobTicketJsaAnalyzeService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票JSA分析-批量删除")
	@Operation(summary="电子作业票JSA分析-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketJsaAnalyze")
	public Result<String> deleteBatchTbJobTicketJsaAnalyze(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketJsaAnalyzeService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketJsaAnalyze")
    public ModelAndView exportTbJobTicketJsaAnalyze(HttpServletRequest request, TbJobTicketJsaAnalyze tbJobTicketJsaAnalyze) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketJsaAnalyze> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketJsaAnalyze, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketJsaAnalyze> pageList = tbJobTicketJsaAnalyzeService.list(queryWrapper);
		 List<TbJobTicketJsaAnalyze> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票JSA分析");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketJsaAnalyze.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票JSA分析报表", "导出人:" + sysUser.getRealname(), "电子作业票JSA分析"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketJsaAnalyze/{mainId}")
    public Result<?> importTbJobTicketJsaAnalyze(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketJsaAnalyze> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketJsaAnalyze.class, params);
				 for (TbJobTicketJsaAnalyze temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketJsaAnalyzeService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票JSA分析-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票气体分析-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票气体分析-通过主表ID查询")
	@Operation(summary="电子作业票气体分析-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketGasAnalysisByMainId")
    public Result<IPage<TbJobTicketGasAnalysis>> listTbJobTicketGasAnalysisByMainId(TbJobTicketGasAnalysis tbJobTicketGasAnalysis,
																					@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
																					@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
																					HttpServletRequest req) {
        QueryWrapper<TbJobTicketGasAnalysis> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketGasAnalysis, req.getParameterMap());
        Page<TbJobTicketGasAnalysis> page = new Page<TbJobTicketGasAnalysis>(pageNo, pageSize);
		/*采样时间倒序排序*/
		queryWrapper.orderByDesc("sampling_time");
        IPage<TbJobTicketGasAnalysis> pageList = tbJobTicketGasAnalysisService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketGasAnalysis
	 * @return
	 */
	@AutoLog(value = "电子作业票气体分析-添加")
	@Operation(summary="电子作业票气体分析-添加")
	@PostMapping(value = "/addTbJobTicketGasAnalysis")
	public Result<String> addTbJobTicketGasAnalysis(@RequestBody TbJobTicketGasAnalysis tbJobTicketGasAnalysis) {
		tbJobTicketGasAnalysisService.save(tbJobTicketGasAnalysis);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketGasAnalysis
	 * @return
	 */
	@AutoLog(value = "电子作业票气体分析-编辑")
	@Operation(summary="电子作业票气体分析-编辑")
	@RequestMapping(value = "/editTbJobTicketGasAnalysis", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketGasAnalysis(@RequestBody TbJobTicketGasAnalysis tbJobTicketGasAnalysis) {
		tbJobTicketGasAnalysisService.updateById(tbJobTicketGasAnalysis);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票气体分析-通过id删除")
	@Operation(summary="电子作业票气体分析-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketGasAnalysis")
	public Result<String> deleteTbJobTicketGasAnalysis(@RequestParam(name="id",required=true) String id) {
		tbJobTicketGasAnalysisService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票气体分析-批量删除")
	@Operation(summary="电子作业票气体分析-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketGasAnalysis")
	public Result<String> deleteBatchTbJobTicketGasAnalysis(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketGasAnalysisService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketGasAnalysis")
    public ModelAndView exportTbJobTicketGasAnalysis(HttpServletRequest request, TbJobTicketGasAnalysis tbJobTicketGasAnalysis) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketGasAnalysis> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketGasAnalysis, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketGasAnalysis> pageList = tbJobTicketGasAnalysisService.list(queryWrapper);
		 List<TbJobTicketGasAnalysis> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票气体分析");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketGasAnalysis.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票气体分析报表", "导出人:" + sysUser.getRealname(), "电子作业票气体分析"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketGasAnalysis/{mainId}")
    public Result<?> importTbJobTicketGasAnalysis(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketGasAnalysis> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketGasAnalysis.class, params);
				 for (TbJobTicketGasAnalysis temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketGasAnalysisService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票气体分析-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票措施落实确认-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票措施落实确认-通过主表ID查询")
	@Operation(summary="电子作业票措施落实确认-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketMeasureRecordByMainId")
    public Result<IPage<TbJobTicketMeasureRecord>> listTbJobTicketMeasureRecordByMainId(TbJobTicketMeasureRecord tbJobTicketMeasureRecord,
																						@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
																						@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
																						HttpServletRequest req) {
        QueryWrapper<TbJobTicketMeasureRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketMeasureRecord, req.getParameterMap());
        Page<TbJobTicketMeasureRecord> page = new Page<TbJobTicketMeasureRecord>(pageNo, pageSize);
        IPage<TbJobTicketMeasureRecord> pageList = tbJobTicketMeasureRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketMeasureRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票措施落实确认-添加")
	@Operation(summary="电子作业票措施落实确认-添加")
	@PostMapping(value = "/addTbJobTicketMeasureRecord")
	public Result<String> addTbJobTicketMeasureRecord(@RequestBody TbJobTicketMeasureRecord tbJobTicketMeasureRecord) {
		tbJobTicketMeasureRecordService.save(tbJobTicketMeasureRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketMeasureRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票措施落实确认-编辑")
	@Operation(summary="电子作业票措施落实确认-编辑")
	@RequestMapping(value = "/editTbJobTicketMeasureRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketMeasureRecord(@RequestBody TbJobTicketMeasureRecord tbJobTicketMeasureRecord) {
		tbJobTicketMeasureRecordService.updateById(tbJobTicketMeasureRecord);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票措施落实确认-通过id删除")
	@Operation(summary="电子作业票措施落实确认-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketMeasureRecord")
	public Result<String> deleteTbJobTicketMeasureRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketMeasureRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票措施落实确认-批量删除")
	@Operation(summary="电子作业票措施落实确认-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketMeasureRecord")
	public Result<String> deleteBatchTbJobTicketMeasureRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketMeasureRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketMeasureRecord")
    public ModelAndView exportTbJobTicketMeasureRecord(HttpServletRequest request, TbJobTicketMeasureRecord tbJobTicketMeasureRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketMeasureRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketMeasureRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketMeasureRecord> pageList = tbJobTicketMeasureRecordService.list(queryWrapper);
		 List<TbJobTicketMeasureRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票措施落实确认");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketMeasureRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票措施落实确认报表", "导出人:" + sysUser.getRealname(), "电子作业票措施落实确认"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketMeasureRecord/{mainId}")
    public Result<?> importTbJobTicketMeasureRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketMeasureRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketMeasureRecord.class, params);
				 for (TbJobTicketMeasureRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketMeasureRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票措施落实确认-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票审核记录-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票审核记录-通过主表ID查询")
	@Operation(summary="电子作业票审核记录-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketExamineRecordByMainId")
    public Result<IPage<TbJobTicketExamineRecord>> listTbJobTicketExamineRecordByMainId(TbJobTicketExamineRecord tbJobTicketExamineRecord,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<TbJobTicketExamineRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketExamineRecord, req.getParameterMap());
        Page<TbJobTicketExamineRecord> page = new Page<TbJobTicketExamineRecord>(pageNo, pageSize);
        IPage<TbJobTicketExamineRecord> pageList = tbJobTicketExamineRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketExamineRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-添加")
	@Operation(summary="电子作业票审核记录-添加")
	@PostMapping(value = "/addTbJobTicketExamineRecord")
	public Result<String> addTbJobTicketExamineRecord(@RequestBody TbJobTicketExamineRecord tbJobTicketExamineRecord) {
		tbJobTicketExamineRecordService.save(tbJobTicketExamineRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketExamineRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-编辑审批")
	@Operation(summary="电子作业票审核记录-编辑审批")
	@RequestMapping(value = "/editTbJobTicketExamineRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketExamineRecord(@RequestBody TbJobTicketExamineRecord tbJobTicketExamineRecord) {
		tbJobTicketExamineRecord.setConfirmationTime(DateUtils.getDate());
		tbJobTicketExamineRecordService.updateById(tbJobTicketExamineRecord);
		return Result.OK("编辑审批成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-通过id删除")
	@Operation(summary="电子作业票审核记录-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketExamineRecord")
	public Result<String> deleteTbJobTicketExamineRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketExamineRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票审核记录-批量删除")
	@Operation(summary="电子作业票审核记录-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketExamineRecord")
	public Result<String> deleteBatchTbJobTicketExamineRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketExamineRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketExamineRecord")
    public ModelAndView exportTbJobTicketExamineRecord(HttpServletRequest request, TbJobTicketExamineRecord tbJobTicketExamineRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketExamineRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketExamineRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketExamineRecord> pageList = tbJobTicketExamineRecordService.list(queryWrapper);
		 List<TbJobTicketExamineRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票审核记录");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketExamineRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票审核记录报表", "导出人:" + sysUser.getRealname(), "电子作业票审核记录"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketExamineRecord/{mainId}")
    public Result<?> importTbJobTicketExamineRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketExamineRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketExamineRecord.class, params);
				 for (TbJobTicketExamineRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketExamineRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票审核记录-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票安全交底-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票安全交底-通过主表ID查询")
	@Operation(summary="电子作业票安全交底-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketSecurityDisclosureRecordByMainId")
    public Result<IPage<TbJobTicketSecurityDisclosureRecord>> listTbJobTicketSecurityDisclosureRecordByMainId(TbJobTicketSecurityDisclosureRecord tbJobTicketSecurityDisclosureRecord,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<TbJobTicketSecurityDisclosureRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketSecurityDisclosureRecord, req.getParameterMap());
        Page<TbJobTicketSecurityDisclosureRecord> page = new Page<TbJobTicketSecurityDisclosureRecord>(pageNo, pageSize);
        IPage<TbJobTicketSecurityDisclosureRecord> pageList = tbJobTicketSecurityDisclosureRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketSecurityDisclosureRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票安全交底-添加")
	@Operation(summary="电子作业票安全交底-添加")
	@PostMapping(value = "/addTbJobTicketSecurityDisclosureRecord")
	public Result<String> addTbJobTicketSecurityDisclosureRecord(@RequestBody TbJobTicketSecurityDisclosureRecord tbJobTicketSecurityDisclosureRecord) {
		tbJobTicketSecurityDisclosureRecordService.save(tbJobTicketSecurityDisclosureRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketSecurityDisclosureRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票安全交底-编辑")
	@Operation(summary="电子作业票安全交底-编辑")
	@RequestMapping(value = "/editTbJobTicketSecurityDisclosureRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketSecurityDisclosureRecord(@RequestBody TbJobTicketSecurityDisclosureRecord tbJobTicketSecurityDisclosureRecord) {
		tbJobTicketSecurityDisclosureRecord.setSecurityDisclosureTime(DateUtils.getDate());
		tbJobTicketSecurityDisclosureRecordService.updateById(tbJobTicketSecurityDisclosureRecord);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票安全交底-通过id删除")
	@Operation(summary="电子作业票安全交底-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketSecurityDisclosureRecord")
	public Result<String> deleteTbJobTicketSecurityDisclosureRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketSecurityDisclosureRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票安全交底-批量删除")
	@Operation(summary="电子作业票安全交底-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketSecurityDisclosureRecord")
	public Result<String> deleteBatchTbJobTicketSecurityDisclosureRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketSecurityDisclosureRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketSecurityDisclosureRecord")
    public ModelAndView exportTbJobTicketSecurityDisclosureRecord(HttpServletRequest request, TbJobTicketSecurityDisclosureRecord tbJobTicketSecurityDisclosureRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketSecurityDisclosureRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketSecurityDisclosureRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketSecurityDisclosureRecord> pageList = tbJobTicketSecurityDisclosureRecordService.list(queryWrapper);
		 List<TbJobTicketSecurityDisclosureRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票安全交底");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketSecurityDisclosureRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票安全交底报表", "导出人:" + sysUser.getRealname(), "电子作业票安全交底"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketSecurityDisclosureRecord/{mainId}")
    public Result<?> importTbJobTicketSecurityDisclosureRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketSecurityDisclosureRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketSecurityDisclosureRecord.class, params);
				 for (TbJobTicketSecurityDisclosureRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketSecurityDisclosureRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票安全交底-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票过程信息-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票过程信息-通过主表ID查询")
	@Operation(summary="电子作业票过程信息-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketCourseRecordByMainId")
    public Result<IPage<TbJobTicketCourseRecord>> listTbJobTicketCourseRecordByMainId(TbJobTicketCourseRecord tbJobTicketCourseRecord,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<TbJobTicketCourseRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketCourseRecord, req.getParameterMap());
        Page<TbJobTicketCourseRecord> page = new Page<TbJobTicketCourseRecord>(pageNo, pageSize);
        IPage<TbJobTicketCourseRecord> pageList = tbJobTicketCourseRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketCourseRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票过程信息-添加")
	@Operation(summary="电子作业票过程信息-添加")
	@PostMapping(value = "/addTbJobTicketCourseRecord")
	public Result<String> addTbJobTicketCourseRecord(@RequestBody TbJobTicketCourseRecord tbJobTicketCourseRecord) {
		tbJobTicketCourseRecordService.save(tbJobTicketCourseRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketCourseRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票过程信息-编辑")
	@Operation(summary="电子作业票过程信息-编辑")
	@RequestMapping(value = "/editTbJobTicketCourseRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketCourseRecord(@RequestBody TbJobTicketCourseRecord tbJobTicketCourseRecord) {
		tbJobTicketCourseRecordService.updateById(tbJobTicketCourseRecord);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票过程信息-通过id删除")
	@Operation(summary="电子作业票过程信息-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketCourseRecord")
	public Result<String> deleteTbJobTicketCourseRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketCourseRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票过程信息-批量删除")
	@Operation(summary="电子作业票过程信息-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketCourseRecord")
	public Result<String> deleteBatchTbJobTicketCourseRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketCourseRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketCourseRecord")
    public ModelAndView exportTbJobTicketCourseRecord(HttpServletRequest request, TbJobTicketCourseRecord tbJobTicketCourseRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketCourseRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketCourseRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketCourseRecord> pageList = tbJobTicketCourseRecordService.list(queryWrapper);
		 List<TbJobTicketCourseRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票过程信息");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketCourseRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票过程信息报表", "导出人:" + sysUser.getRealname(), "电子作业票过程信息"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketCourseRecord/{mainId}")
    public Result<?> importTbJobTicketCourseRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketCourseRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketCourseRecord.class, params);
				 for (TbJobTicketCourseRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketCourseRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票过程信息-end----------------------------------------------*/

	 /*--------------------------------子表处理-电子作业票验收-begin----------------------------------------------*/
	 /**
	  * 通过主表ID查询
	  * @return
	  */
	 //@AutoLog(value = "电子作业票验收-通过主表ID查询")
	 @Operation(summary="电子作业票验收-通过主表ID查询")
	 @GetMapping(value = "/listTbJobTicketAcceptanceCheckRecordByMainId")
	 public Result<IPage<TbJobTicketAcceptanceCheckRecord>> listTbJobTicketAcceptanceCheckRecordByMainId(TbJobTicketAcceptanceCheckRecord tbJobTicketAcceptanceCheckRecord,
																										 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
																										 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
																										 HttpServletRequest req) {
		 QueryWrapper<TbJobTicketAcceptanceCheckRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketAcceptanceCheckRecord, req.getParameterMap());
		 Page<TbJobTicketAcceptanceCheckRecord> page = new Page<TbJobTicketAcceptanceCheckRecord>(pageNo, pageSize);
		 IPage<TbJobTicketAcceptanceCheckRecord> pageList = tbJobTicketAcceptanceCheckRecordService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }

	 /**
	  * 添加
	  * @param tbJobTicketAcceptanceCheckRecord
	  * @return
	  */
	 @AutoLog(value = "电子作业票验收-添加")
	 @Operation(summary="电子作业票验收-添加")
	 @PostMapping(value = "/addTbJobTicketAcceptanceCheckRecord")
	 public Result<String> addTbJobTicketAcceptanceCheckRecord(@RequestBody TbJobTicketAcceptanceCheckRecord tbJobTicketAcceptanceCheckRecord) {
		 tbJobTicketAcceptanceCheckRecordService.save(tbJobTicketAcceptanceCheckRecord);
		 return Result.OK("添加成功！");
	 }

	 /**
	  * 编辑
	  * @param tbJobTicketAcceptanceCheckRecord
	  * @return
	  */
	 @AutoLog(value = "电子作业票验收-编辑验收成功")
	 @Operation(summary="电子作业票验收-编辑验收成功")
	 @RequestMapping(value = "/editTbJobTicketAcceptanceCheckRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	 public Result<String> editTbJobTicketAcceptanceCheckRecord(@RequestBody TbJobTicketAcceptanceCheckRecord tbJobTicketAcceptanceCheckRecord) {
		 tbJobTicketAcceptanceCheckRecord.setAcceptanceCheckTime(DateUtils.getDate());
		 tbJobTicketAcceptanceCheckRecordService.updateById(tbJobTicketAcceptanceCheckRecord);
		 return Result.OK("编辑成功验收成功!");
	 }

	 /**
	  * 通过id删除
	  * @param id
	  * @return
	  */
	 @AutoLog(value = "电子作业票验收-通过id删除")
	 @Operation(summary="电子作业票验收-通过id删除")
	 @DeleteMapping(value = "/deleteTbJobTicketAcceptanceCheckRecord")
	 public Result<String> deleteTbJobTicketAcceptanceCheckRecord(@RequestParam(name="id",required=true) String id) {
		 tbJobTicketAcceptanceCheckRecordService.removeById(id);
		 return Result.OK("删除成功!");
	 }

	 /**
	  * 批量删除
	  * @param ids
	  * @return
	  */
	 @AutoLog(value = "电子作业票验收-批量删除")
	 @Operation(summary="电子作业票验收-批量删除")
	 @DeleteMapping(value = "/deleteBatchTbJobTicketAcceptanceCheckRecord")
	 public Result<String> deleteBatchTbJobTicketAcceptanceCheckRecord(@RequestParam(name="ids",required=true) String ids) {
		 this.tbJobTicketAcceptanceCheckRecordService.removeByIds(Arrays.asList(ids.split(",")));
		 return Result.OK("批量删除成功!");
	 }

	 /**
	  * 导出
	  * @return
	  */
	 @RequestMapping(value = "/exportTbJobTicketAcceptanceCheckRecord")
	 public ModelAndView exportTbJobTicketAcceptanceCheckRecord(HttpServletRequest request, TbJobTicketAcceptanceCheckRecord tbJobTicketAcceptanceCheckRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketAcceptanceCheckRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketAcceptanceCheckRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketAcceptanceCheckRecord> pageList = tbJobTicketAcceptanceCheckRecordService.list(queryWrapper);
		 List<TbJobTicketAcceptanceCheckRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票验收");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketAcceptanceCheckRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票验收报表", "导出人:" + sysUser.getRealname(), "电子作业票验收"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
	 }

	 /**
	  * 导入
	  * @return
	  */
	 @RequestMapping(value = "/importTbJobTicketAcceptanceCheckRecord/{mainId}")
	 public Result<?> importTbJobTicketAcceptanceCheckRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
			 // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketAcceptanceCheckRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketAcceptanceCheckRecord.class, params);
				 for (TbJobTicketAcceptanceCheckRecord temp : list) {
					 temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketAcceptanceCheckRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
	 }

	 /*--------------------------------子表处理-电子作业票验收-end----------------------------------------------*/

	 /*--------------------------------子表处理-电子作业票问题-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票问题-通过主表ID查询")
	@Operation(summary="电子作业票问题-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketProblemRecordByMainId")
    public Result<IPage<TbJobTicketProblemRecord>> listTbJobTicketProblemRecordByMainId(TbJobTicketProblemRecord tbJobTicketProblemRecord,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<TbJobTicketProblemRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketProblemRecord, req.getParameterMap());
        Page<TbJobTicketProblemRecord> page = new Page<TbJobTicketProblemRecord>(pageNo, pageSize);
        IPage<TbJobTicketProblemRecord> pageList = tbJobTicketProblemRecordService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketProblemRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票问题-添加")
	@Operation(summary="电子作业票问题-添加")
	@PostMapping(value = "/addTbJobTicketProblemRecord")
	public Result<String> addTbJobTicketProblemRecord(@RequestBody TbJobTicketProblemRecord tbJobTicketProblemRecord) {
		tbJobTicketProblemRecordService.save(tbJobTicketProblemRecord);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketProblemRecord
	 * @return
	 */
	@AutoLog(value = "电子作业票问题-编辑")
	@Operation(summary="电子作业票问题-编辑")
	@RequestMapping(value = "/editTbJobTicketProblemRecord", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketProblemRecord(@RequestBody TbJobTicketProblemRecord tbJobTicketProblemRecord) {
		tbJobTicketProblemRecordService.updateById(tbJobTicketProblemRecord);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票问题-通过id删除")
	@Operation(summary="电子作业票问题-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketProblemRecord")
	public Result<String> deleteTbJobTicketProblemRecord(@RequestParam(name="id",required=true) String id) {
		tbJobTicketProblemRecordService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票问题-批量删除")
	@Operation(summary="电子作业票问题-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketProblemRecord")
	public Result<String> deleteBatchTbJobTicketProblemRecord(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketProblemRecordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketProblemRecord")
    public ModelAndView exportTbJobTicketProblemRecord(HttpServletRequest request, TbJobTicketProblemRecord tbJobTicketProblemRecord) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketProblemRecord> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketProblemRecord, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketProblemRecord> pageList = tbJobTicketProblemRecordService.list(queryWrapper);
		 List<TbJobTicketProblemRecord> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票问题");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketProblemRecord.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票问题报表", "导出人:" + sysUser.getRealname(), "电子作业票问题"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketProblemRecord/{mainId}")
    public Result<?> importTbJobTicketProblemRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketProblemRecord> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketProblemRecord.class, params);
				 for (TbJobTicketProblemRecord temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketProblemRecordService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票问题-end----------------------------------------------*/

    /*--------------------------------子表处理-电子作业票违章抓拍-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "电子作业票违章抓拍-通过主表ID查询")
	@Operation(summary="电子作业票违章抓拍-通过主表ID查询")
	@GetMapping(value = "/listTbJobTicketViolationCaptureByMainId")
    public Result<IPage<TbJobTicketViolationCapture>> listTbJobTicketViolationCaptureByMainId(TbJobTicketViolationCapture tbJobTicketViolationCapture,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<TbJobTicketViolationCapture> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketViolationCapture, req.getParameterMap());
        Page<TbJobTicketViolationCapture> page = new Page<TbJobTicketViolationCapture>(pageNo, pageSize);
        IPage<TbJobTicketViolationCapture> pageList = tbJobTicketViolationCaptureService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param tbJobTicketViolationCapture
	 * @return
	 */
	@AutoLog(value = "电子作业票违章抓拍-添加")
	@Operation(summary="电子作业票违章抓拍-添加")
	@PostMapping(value = "/addTbJobTicketViolationCapture")
	public Result<String> addTbJobTicketViolationCapture(@RequestBody TbJobTicketViolationCapture tbJobTicketViolationCapture) {
		tbJobTicketViolationCaptureService.save(tbJobTicketViolationCapture);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param tbJobTicketViolationCapture
	 * @return
	 */
	@AutoLog(value = "电子作业票违章抓拍-编辑")
	@Operation(summary="电子作业票违章抓拍-编辑")
	@RequestMapping(value = "/editTbJobTicketViolationCapture", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editTbJobTicketViolationCapture(@RequestBody TbJobTicketViolationCapture tbJobTicketViolationCapture) {
		tbJobTicketViolationCaptureService.updateById(tbJobTicketViolationCapture);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "电子作业票违章抓拍-通过id删除")
	@Operation(summary="电子作业票违章抓拍-通过id删除")
	@DeleteMapping(value = "/deleteTbJobTicketViolationCapture")
	public Result<String> deleteTbJobTicketViolationCapture(@RequestParam(name="id",required=true) String id) {
		tbJobTicketViolationCaptureService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "电子作业票违章抓拍-批量删除")
	@Operation(summary="电子作业票违章抓拍-批量删除")
	@DeleteMapping(value = "/deleteBatchTbJobTicketViolationCapture")
	public Result<String> deleteBatchTbJobTicketViolationCapture(@RequestParam(name="ids",required=true) String ids) {
	    this.tbJobTicketViolationCaptureService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportTbJobTicketViolationCapture")
    public ModelAndView exportTbJobTicketViolationCapture(HttpServletRequest request, TbJobTicketViolationCapture tbJobTicketViolationCapture) {
		 // Step.1 组装查询条件
		 QueryWrapper<TbJobTicketViolationCapture> queryWrapper = QueryGenerator.initQueryWrapper(tbJobTicketViolationCapture, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<TbJobTicketViolationCapture> pageList = tbJobTicketViolationCaptureService.list(queryWrapper);
		 List<TbJobTicketViolationCapture> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "电子作业票违章抓拍");
		 mv.addObject(NormalExcelConstants.CLASS, TbJobTicketViolationCapture.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("电子作业票违章抓拍报表", "导出人:" + sysUser.getRealname(), "电子作业票违章抓拍"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importTbJobTicketViolationCapture/{mainId}")
    public Result<?> importTbJobTicketViolationCapture(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<TbJobTicketViolationCapture> list = ExcelImportUtil.importExcel(file.getInputStream(), TbJobTicketViolationCapture.class, params);
				 for (TbJobTicketViolationCapture temp : list) {
                    temp.setJobTicketId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 tbJobTicketViolationCaptureService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-电子作业票违章抓拍-end----------------------------------------------*/


	 /**
	  * 获取编号
	  * @return
	  */
	 @AutoLog(value = "电子作业票审核记录-获取编号")
	 @Operation(summary="电子作业票审核记录-获取编号")
	 @GetMapping(value = "/queryJobCode")
	 public Result<String> queryJobCode() {
		 //String code = new JobTicketNumberRule().execute(null,null).toString();
		 return Result.OK("获取编号成功！", TicketGenerator.getInstance().generateTicketNumber());
	 }

	 /**
	  * 作业活动根据作业类型查询开具的作业票数量
	  * @return
	  */
	 @AutoLog(value = "电子作业票-作业活动根据作业类型查询开具的作业票数量")
	 @Operation(summary="电子作业票-作业活动根据作业类型查询开具的作业票数量")
	 @GetMapping(value = "/queryJobCountByEventIdAndJobType")
	 public Result<List<CommonVo>> queryJobCountByEventIdAndJobType(TbJobTicket tbJobTicket) {
		 List<CommonVo> mapList = new ArrayList<>();
		 String[] jobTypeList = tbJobTicket.getJobType().split(",");
		 for (String typeValue : jobTypeList) {
			 CommonVo commonVo = new CommonVo();
			 QueryWrapper<TbJobTicket> queryWrapper = new QueryWrapper<>();
			 queryWrapper.eq("job_type",typeValue);
			 queryWrapper.eq("events_id",tbJobTicket.getEventsId());
			 long count = tbJobTicketService.count(queryWrapper);
			 commonVo.setKey(typeValue);
			 commonVo.setValue(String.valueOf(count));
			 mapList.add(commonVo);
		 }
		 return Result.OK("获取作业活动根据作业类型查询开具的作业票数量！", mapList);
	 }

}
